package app

import (
	"app/internal/db"
	"github.com/go-redis/redis/v8"
	"github.com/spf13/viper"
)

// redis客户端
var (
	RedisClient *redis.Client
	Viper       *viper.Viper
)

// 项目初始化
func init() {
	//读取配置文件
	Viper = viper.New()
	Viper.SetConfigFile("./config/config.yaml")
	if err := Viper.ReadInConfig(); err != nil {
		panic("Failed to read config file: " + err.Error())
	}

	//实例化redis客户端对象
	RedisClient = db.ConnRedis(Viper.GetString("redis.ip"), Viper.GetString("redis.port"), Viper.GetString("redis.pass"), Viper.GetInt("redis.db"))
}
